import Vue from "vue";
import Vuex from "vuex";
const actions = {
  jia(conTxt, value) {
    conTxt.commit("JIA", value);
  },
  jian(conTxt, value) {
    conTxt.commit("JIAN", value);
  },
  addodd(conTxt, value) {
    conTxt.commit("ADDODD", value);
  },
  addWait(conTxt, value) {
    conTxt.commit("ADDWait", value);
  },
};
const mutations = {
  JIA(state, value) {
    state.sum += value;
  },
  JIAN(state, value) {
    state.sum -= value;
  },
  ADDODD(state, value) {
    if (state.sum % 2) {
      state.sum += value;
    }
  },
  ADDWait(state, value) {
    setTimeout(() => {
      state.sum += value;
    }, 500);
  },
};
const state = {
  sum: 0,
};
Vue.use(Vuex);
export default new Vuex.Store({
  actions,
  mutations,
  state,
});
